Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Adds check for parent before showing convert to pattern button #66158

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

vipul0425
Copy link
Contributor

What?

Fixes: #35223

Why?

When a block defines a parent it was still possible to select the "child" block and make it reusable.

How?

This PR adds a check for "parent" type before showing the "convert to patterns" (reusable). It adds the default value of reusable support to false if not defined in the block supports.

Testing Instructions

  1. Create a custom block with parent key.
  2. Insert the block in the parent container block.
  3. Select the "child block" and click on the 3 dots in Blocks List view in editor.
  4. It should not show the "Convert to pattern" button until we intentionally specifies the "reusable" support to true in Child Block's block.json

Screenshots

Default State (Without adding reusable key in support)
image

After defining reusable as true
image

Copy link

github-actions bot commented Oct 16, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vipul0425 <[email protected]>
Co-authored-by: gziolo <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: mtias <[email protected]>
Co-authored-by: aristath <[email protected]>
Co-authored-by: jordesign <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@draganescu draganescu added [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. labels Oct 16, 2024
@draganescu draganescu requested a review from aristath October 16, 2024 08:12
@gziolo
Copy link
Member

gziolo commented Oct 22, 2024

That looks like a reasonable fix to me. I would feel more confident landing this change if we had an e2e test covering it. That's said I will test it manually.

@Mamaduka
Copy link
Member

I thought the plan was to set this at the block registration level. Or would that be too unexpected for consumers?

@gziolo
Copy link
Member

gziolo commented Oct 23, 2024

I thought the plan was to set this at the block registration level. Or would that be too unexpected for consumers?

That is also a possibility. However, the logic used here mostly impacts how the default value is computed. If the block explicitly defines support for reusable, it will be respected. I'm fine with both approaches. We can land this enhancement and refactor later, too.

@gziolo gziolo requested review from a team and ellatrix and removed request for a team October 23, 2024 10:01
@ntsekouras
Copy link
Contributor

Is there something more to address in order to land? This seems a good approach and ready.

@vipul0425
Copy link
Contributor Author

Hi @gziolo, just checking in—please let me know if there's anything pending from my side to get this PR landed. Thanks!

@gziolo gziolo merged commit 7639ed8 into WordPress:trunk Nov 20, 2024
76 checks passed
@gziolo
Copy link
Member

gziolo commented Nov 20, 2024

All good, landed 👍🏻

@gziolo gziolo changed the title Feat: Adds check for parent before showing convert to pattern button. Blocks: Adds check for parent before showing convert to pattern button Nov 20, 2024
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically set reusable to false when a block has a parent defined
5 participants